package com.trkj.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.trkj.service.EmpRoleService;
import com.trkj.utils.DataGrid;
import com.trkj.vo.EmpMenuRoleVo;
/**
 * 权限管理的角色管理controller
 * @author 吴山峰
 *
 */
@Controller
@SessionAttributes({"emp", "funcIds"})
public class EmpRoleController {
	@Autowired
	EmpRoleService empRoleService;
	/**
	 * 前往权限用户管理EpmRoleInfo.jsp页面
	 */
	@RequestMapping("/to_EmpRoleInfo")
	public String toEmpRoleInfo() {
		return "EmpRoleInfo";
	}
	/**
	 * 前往权限角色EpmRoleInfo.jsp页面
	 */
	@RequestMapping("/to_GiveEmpRole")
	public String toGiveEmpRole() {
		return "GiveEmpRole";
	}
	
	/**
	 * 查询所有员工||根据员工名模糊查询员工
	 * @return 
	 */
	@RequestMapping("/get_allEmp")
	@ResponseBody
	public DataGrid findEmpByLikeName(String empname, Integer page, Integer rows,
			@RequestParam(required=false,defaultValue="empId") String sort,
			@RequestParam(required=false,defaultValue="desc") String order) {
		return empRoleService.pageSelect(empname, page, rows, sort, order);
	}
	/**
	 * 根据员工id查询该员工拥有的角色
	 * @param empid
	 * @return
	 */
	@RequestMapping("/get_EmpRole")
	@ResponseBody
	public List<EmpMenuRoleVo> findEmpRoleById(Integer empid) {
		return empRoleService.findEmpRoleById(empid);
	}
	/**
	 * 给员工指定角色
	 */
	@RequestMapping("/give_EmpRole")
	@ResponseBody
	public boolean giveEmpRoleById(Integer empid, String roleids) {
		return empRoleService.giveEmpRoleById(empid, roleids);
	}
}
